package com.org.oracle.mongodb.entity;

import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.mongodb.core.mapping.Document;

import java.io.IOException;

/**
 * @author suze
 * @date 2024/8/15
 * @time 14:22
 **/
@Data
@Builder
@Document("user")
public class User {
    /**
     * 头像
     */
    private String avatar;
    private String name;
    private String uid;

    /**
     * 回调方传来的标识
     * 如：微信openid
     */
    private String openid;

    /**
     * 地区
     */
    private String address;
    @Override
    public String toString() {
        try {
            ObjectMapper mapper = new ObjectMapper();
            return mapper.writeValueAsString(this);
        } catch (IOException e) {
            // Handle exception
            e.printStackTrace();
            return "Error converting to JSON: " + e.getMessage();
        }
    }
}

